<template id="all_evaluation">
	<div class="all_evaluation">

		<!--头部-->
		<div class="about_header">

			<div class="about_title">
				<span @click.stop="backAll"><img src="../../assets/images/class/jiantou_03.png" /></span>

				<p>所有评价</p>
				<div class="about_select">
					<div class="about_ing"></div>
				</div>

			</div>
		</div>
		<!--头部结束-->

		<!--用户的留言-->
		<div class="about_word">
			<h1 v-if="sumNum">课程评价 ({{sumNum}})</h1>
			<div class="about_wrap" v-for="(list,index) in eval">
				<dl>
					<dt><img :src="list.userphoto"/></dt>
					<dd>
						<p>{{list.username}}</p>
						<span>{{list.create_time | formatDate}}</span>

					</dd>
				</dl>
				<p>{{list.content}}</p>
			</div>

		</div>
		<!--用户的留言结束-->
	</div>
</template>

<script>
	export default {
		name: 'BusImg',
		data() {

			return {

				eval: [],
				sumNum: '',
				coachid: this.$route.query.coachid,

			}

		},
		components: {},
		created() {
			let obj = {
				//请求的参数
				coachid: this.$route.query.coachid,
				code: 1,

			};
			var _this = this
			let qs = require('qs');
			this.$axios.post("http://yogahome.top/yujia/coach/showCoachHomepage", qs.stringify(obj), {
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
				//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串 
			}).then(function(response) {
				_this.eval = response.data.data.evaluate
				_this.sumNum = _this.eval.length;
				for(let i=0;i<_this.eval.length;i++){
					_this.eval[i].content = decodeURI(response.data.data.evaluate[i].content);
				}
				 
			}).catch(function(error) {
				console.log(error);
			});
		},
		//将时间戳转换成日期格式
		filters: {
			formatDate: function(value) {
				let date = new Date(value);
				let y = date.getFullYear();
				let MM = date.getMonth() + 1;
				MM = MM < 10 ? ('0' + MM) : MM;
				let d = date.getDate();
				d = d < 10 ? ('0' + d) : d;
				let h = date.getHours();
				h = h < 10 ? ('0' + h) : h;
				let m = date.getMinutes();
				m = m < 10 ? ('0' + m) : m;
				let s = date.getSeconds();
				s = s < 10 ? ('0' + s) : s;
				return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
			}
		},
		methods: {
			backAll() {
				this.$router.push({
					path: "/about_coach",
					query: {
						coachid: this.$route.query.coachid
					}
				})
			}
		},

	}
</script>

<style scoped>
	@import "../../assets/css/all_evaluation.css";
</style>